package com.artfii.fluentsql.example;

import com.artfii.fluentsql.core.jdbc.ConnectionProvider;
import org.springframework.jdbc.datasource.DataSourceUtils;
import org.springframework.stereotype.Service;

import javax.sql.DataSource;
import java.sql.Connection;

/**
 * Func:  Spring Connection 创建
 *
 * @author : Lqf(leeton)
 * @date : 2021/5/31.
 */
@Service
public class SpringConnectionProvider implements ConnectionProvider {
    @Override
    public Connection buildOfDs(DataSource dataSource) {
        //调用spring的DataSourceUtils来创建connection，以实现事务管理
        return DataSourceUtils.getConnection(dataSource);
    }

}
